from tj3.models import *
from django.contrib import admin
from mptt.admin import MPTTModelAdmin

class ProjectAdmin(admin.ModelAdmin):
	list_display=('name','start','end','description')
	list_filter=['start','end']
	list_select_related=True
admin.site.register(Project,ProjectAdmin)

class ResourceAdmin(admin.ModelAdmin):
	list_display=('first_name','last_name')
	list_select_related=True
admin.site.register(Resource,ResourceAdmin)

admin.site.register(Daypart)

class TaskAdmin(MPTTModelAdmin):
	list_display=('id', 'name','description','full_path')
	list_filter=['project']
	list_select_related=True
admin.site.register(Task,TaskAdmin) # mptt tree


class BookingAdmin(admin.ModelAdmin):
	list_display=('task','resource','when','part_of_day','length')
	list_filter=['task','resource','when']
	list_select_related=True
admin.site.register(Booking, BookingAdmin)

class JournalAdmin(admin.ModelAdmin):
	list_display=('created','booking','summary','memo')
	#list_filter=['booking']
	list_select_related=True
admin.site.register(Journal,JournalAdmin)

class TaskDependencyAdmin(admin.ModelAdmin):
	list_display=('from_task','type','to_task','on_what','gap_duration','gap_length')
	list_filter=['type','from_task','to_task','on_what']
	list_select_related=True
admin.site.register(TaskDependency, TaskDependencyAdmin)

class TimeOffAdmin (admin.ModelAdmin):
	list_display=('start','end','memo')
	list_filter=['start','end']
	list_select_related=True
admin.site.register(TimeOff,TimeOffAdmin)

class ProjectScenarioAdmin(MPTTModelAdmin):
	list_display=('name','description','projection','parent')
	list_filter=['name','projection']
	list_select_related=True
admin.site.register(ProjectScenario, ProjectScenarioAdmin)

class TaskPeriodAdmin(admin.ModelAdmin):
	list_display=('task','scenario','milestone','start','end','duration','length','effort')
	list_filter=['task','scenario','milestone','start','end','duration','length','effort']
	list_select_related=True
admin.site.register(TaskPeriod, TaskPeriodAdmin)

class WorkLimitAdmin(admin.ModelAdmin):
	list_display=('id','dailymax','dailymin','weeklymax','weeklymin','monthlymax','monthlymin','maximum','minimum')
	list_select_related=True
admin.site.register(WorkLimit,WorkLimitAdmin)

class AllocateResourceAdmin(admin.ModelAdmin):
	list_display=('primary','alternative')
	list_select_related=True
admin.site.register(AllocateResource,AllocateResourceAdmin)
